USE [pos]
GO

/****** Object:  Trigger [trg_SaleItem_U_UpdateUpdatedOn]    Script Date: 04/01/2012 16:33:31 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[trg_SaleItem_U_UpdateUpdatedOn]'))
DROP TRIGGER [dbo].[trg_SaleItem_U_UpdateUpdatedOn]
GO

USE [pos]
GO

/****** Object:  Trigger [dbo].[trg_SaleItem_U_UpdateUpdatedOn]    Script Date: 04/01/2012 16:33:31 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Jonathan Loe
-- Create date: 01 April 2012
-- Description:	Automatically update UpdateOn on every update
-- =============================================
CREATE TRIGGER [dbo].[trg_SaleItem_U_UpdateUpdatedOn] 
   ON  [dbo].[SaleItem]
   AFTER UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    UPDATE dbo.[SaleItem]
    SET    dbo.[SaleItem].UpdatedOn = GETDATE()
    FROM   inserted
    WHERE  dbo.[SaleItem].Id = inserted.Id
END

GO


